home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news
- From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
- Newsgroups: comp.lang.c++
- Subject: Re: strstream destruction
- Date: Wed, 03 Apr 1996 16:44:33 +0200
- Organization: Fachbereich Informatik, TH Darmstadt
- Message-ID: <31628ED1.2781E494@intellektik.informatik.th-darmstadt.de>
- References: <315AD92C.726D@itd.ssb.com> <4jhgt0$17f@piper.logicon.com> <4joujt$72p@lib104.its.rpi.edu> <4jttdk$i6v@HOPPER.ACM.ORG>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
-
- Ken Varn wrote:
- >
- > ...
- >
- > Just curious about this as it indirecly applies to something that I am
- > wondering about. If a_stream is declared globally or as a data member of a
- > class, and you were to perform this function with it, would its internal
- > buffer get dynamically reallocated on each call, or would the object maintain
- > its own internal buffer and increase or decrease its size as needed (see
- > below)?
- >
- > ostrstream a_stream;
- >
- > String StrStrFunc ( void ) // some function using strstream
- > {
- > String a_string ; // a 'string' class (char *)
- >
- > a_stream << a_variable // any type
- > << ends ; // null terminate string
- >
- > a_string = a_stream.str() ; // get the buffer
- >
- > a_stream.freeze(0) ; // unfreeze buffer
- >
- > return ( a_string ) ; // out of scope, deletes string
- > // returns copy
- > }
-
- According to the DWP the buffer is only destructed when the
- appropriate 'ostrstream' instance goes out of scope.
- 'freeze(0)' only marks the buffer as 'destroyable' but doesn't
- destroy it. Therefore only the 'frozen' flag is toggled in the
- given example.
-
- Enno
-